/*
 * UMediaFormat.h
 *
 *  Created on: 2020年3月26日
 *      Author: chuanjiang.zh
 */

#ifndef UMEDIAFORMAT_H_
#define UMEDIAFORMAT_H_

#include "UMediaType.h"

class MediaFormatPrivate;

class DLLEXPORT UMediaFormat
{
public:
	UMediaFormat();
	virtual ~UMediaFormat();

	int m_duration;         // millisecond

	int m_codec;
	int m_width;
	int m_height;
	int m_framerate;
	int m_bitrate;
	int m_profile;			/// video codec profile
	int m_level;
	int m_gop;
	int m_clockRate;

	int m_audioCodec;
	int m_audioProfile;		/// audio codec profile
	int m_channels;
	int m_sampleRate;
	int m_sampleBits;
	int m_frameSize;
	int m_audioBitrate;
	int m_audioRate;

	int	m_subtitle;		///
	int m_videoDuration;

	UMediaFormat(const UMediaFormat& fmt);
	UMediaFormat& operator = (const UMediaFormat& fmt);

	UMediaFormat& assign(const UMediaFormat& fmt);


	bool hasVideo() const
	{
		return (m_codec != 0);
	}

	bool hasAudio() const
	{
		return (m_audioCodec != 0);
	}

	bool isValid() const
	{
		return (m_codec != 0) || (m_audioCodec != 0);
	}

	void clear();
	void copyVideo(const UMediaFormat& fmt);
	void copyAudio(const UMediaFormat& fmt);

	size_t getVideoPropSize() const;

	const uint8_t* getVideoProp() const;
	size_t getAudioConfigSize() const;

	const uint8_t* getAudioConfig() const;

	void setVideoProp(const uint8_t* data, size_t length);

	void setVideoProp(const char* data, size_t length);

	void setAudioConfig(const uint8_t* data, size_t length);

	void setAudioConfig(const char* data, size_t length);

	void clearVideoProp();
	void clearAudioConfig();

private:
	MediaFormatPrivate*	m_pimpl;

};

#endif /* UMEDIAFORMAT_H_ */
